package com.cxyzy.basic_libs.view

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View

/**
 * 发光点
 */
class ShiningPoint(context: Context, attributeSet: AttributeSet? = null) :
    View(context, attributeSet) {
    private var mPaint: Paint = Paint()
    private val radius = 50f
    private var centerX: Float = 0f
    private var centerY: Float = 0f

    init {
        mPaint.isAntiAlias = true
    }

    override fun onDraw(canvas: Canvas) {
        centerX = (width / 2).toFloat()
        centerY = (height / 2).toFloat()
        val radialGradient = RadialGradient(
            centerX,
            centerY,
            radius,
            Color.parseColor("#FFD700"),
            Color.WHITE,
            Shader.TileMode.CLAMP
        )
        mPaint.shader = radialGradient
        canvas.drawCircle(centerX, centerY, radius, mPaint)
    }
}